#!/bin/bash

echo "========================================"
echo "开始编译 TimedRequest (Windows x86)"
echo "========================================"

echo ""
echo "[1/3] 清理旧的编译文件..."
rm -rf dist
mkdir -p dist

echo ""
echo "[2/3] 编译 Windows x86 版本..."
GOOS=windows GOARCH=386 CGO_ENABLED=0 go build -ldflags="-s -w" -o dist/TimedRequest_x86.exe main.go

if [ $? -ne 0 ]; then
    echo ""
    echo "❌ 编译失败！"
    exit 1
fi

echo ""
echo "[3/3] 复制配置文件..."
cp config.yaml dist/config.yaml

echo ""
echo "========================================"
echo "✅ 编译完成！"
echo "========================================"
echo ""
echo "输出目录: dist/"
echo "可执行文件: TimedRequest_x86.exe"
echo "配置文件: config.yaml"
echo ""
ls -lh dist/
echo ""
echo "文件已准备好，可以复制到 Windows 系统使用"